<template>
  <div>
    <el-form :model="model" ref="tableForm" size="small" label-width="auto" label-position="top" :rules="formRules">
      <el-row :gutter="30">
        <el-col :span="12">
          <el-form-item label="模块名" prop="moduleName">
            <el-input v-model="model.moduleName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="数据表名" prop="tableName">
            <el-input v-model="model.tableName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="实体类名" prop="entityName">
            <el-input v-model="model.entityName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="包路径" prop="packagePath">
            <el-input v-model="model.packagePath"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="view路径" prop="viewPath">
            <el-input v-model="model.viewPath"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="权限标识" prop="permission">
            <el-input v-model="model.permission"></el-input>
          </el-form-item>
        </el-col>
        <!--        <el-col :span="12">
                  <el-form-item label=""></el-form-item>
                </el-col>-->
      </el-row>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'GenModuleForm',
  props: {
    method: {
      type: String,
      required: true
    },
    model: {
      type: Object,
      required: true
    }
  },
  created () {
  },
  data () {
    return {
      process: { formLoading: false },
      formData: {
        tableName: '',
        entityName: '',
        packagePath: 'com.jeeplus.modules'
      },
      formRules: {
        moduleName: {
          required: true,
          message: '模块名不能为空',
          trigger: 'blur'
        },
        tableName: {
          required: true,
          message: '数据表名不能为空',
          trigger: 'blur'
        },
        entityName: {
          required: true,
          message: '实体类名不能为空',
          trigger: 'blur'
        },
        packagePath: {
          required: true,
          message: '包名不能为空',
          trigger: 'blur'
        }
      }
    }
  },
  computed: {
    loading () {
      return this.process.formLoading
    }
  },
  watch: {
    id (newValue) {
      console.log('id', newValue)
    },
    method (newValue) {
      console.log('method', newValue)
    }
  },
  methods: {
    resetForm () {
      this.$refs.tableForm.resetFields()
    },
    submitForm () {
      return this.$refs.tableForm.validate()
    },
    getFormData () {
      return this.formData
    },
    submitData () {
      this.$http.post('/generator/code/save', this.formData).then(({ data }) => {
        return data
      })
    }
  }
}
</script>

<style scoped>

</style>
